package com.yc.damai.controller;


import com.yc.damai.entity.Orders;
import com.yc.damai.service.IOrdersService;
import com.yc.damai.vo.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ly
 * @since 2022-11-01
 */
@RestController
@RequestMapping("/damai/orders")
public class OrdersController {

    @Resource
    private IOrdersService service;

    @RequestMapping("createOrder")
    public Result createOrder(
            @RequestBody Orders orders) {
        try{
            service.saveOrder(orders);
            return new Result(1, "订单提交成功!", null);
        } catch ( Exception e) {
            e.printStackTrace();
            return new Result(0, "订单提交失败!", null);
        }
    }

}

